package com.niguang.work.labour.api.controller;

import com.niguang.work.labour.api.service.AdminLaborUserService;
import com.niguang.work.labour.common.pojo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 83673
 * @since 2018-11-17
 */
@RestController
@RequestMapping("/adminLaborUser/")
public class AdminLaborUserController {

    @Autowired
    private AdminLaborUserService adminLaborUserService;

    /**
     * 用户登录
     *
     * @param userPhone
     * @param pwd
     * @return
     */
    @GetMapping("loginUser")
    public Result loginUser(@NotNull @RequestParam String userPhone,
                            @NotNull @RequestParam String pwd) {
        return adminLaborUserService.loginUser(userPhone, pwd);
    }

    /**
     * 用户注册
     *
     * @param phone
     * @param pwd
     * @param code
     * @return
     */
    @PostMapping("register")
    public Result register(@RequestParam String phone, @RequestParam String pwd, @RequestParam String code) {

          return  adminLaborUserService.register(phone,pwd,code);
    }


    /**
     * 用户注册下一步
     * @param userId
     * @param companyName
     * @param address
     * @param license
     * @param userName
     * @param idCard
     * @param licenseImg
     * @param idCardFront
     * @param idCardBack
     * @return
     */
    @PostMapping("register/addCompany")
    public Result addCompany(@RequestParam Long userId, @RequestParam String companyName, @RequestParam String address,
                             @RequestParam String license, @RequestParam String userName, @RequestParam String idCard,
                             @RequestParam String licenseImg, @RequestParam String idCardFront, @RequestParam String idCardBack)
    {
        return  adminLaborUserService.addCompany(userId,companyName,address,license,userName,idCard,licenseImg,licenseImg,idCardFront,idCardBack);

    }

    /**
     * 发送验证码
     * @param phone
     * @return
     */
    @GetMapping("/register/sendCode")
    public Result sendCode(@RequestParam String phone) {
        return  adminLaborUserService.sendCode(phone);
    }


}

